package cn.zaichi.edu.excelcommon.style.impl;

import cn.zaichi.edu.excelcommon.style.TitleStyle;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.FillPatternType;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.VerticalAlignment;

public class DefultTitleStyle implements TitleStyle {
    @Override
    public HSSFCellStyle getTitleStyle(HSSFWorkbook workbook) {
        //创建单元格样式
        HSSFCellStyle cell_style = workbook.createCellStyle();
        cell_style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
        cell_style.setFillForegroundColor((short)41);
        cell_style.setVerticalAlignment(VerticalAlignment.CENTER);// 垂直
        cell_style.setAlignment(HorizontalAlignment.CENTER);// 水平

        //设置边框为白色
        //cell_style.setFillForegroundColor((short)9);
        //设置边框属性
        cell_style.setBorderBottom(BorderStyle.THIN); //下边框
        cell_style.setBorderLeft(BorderStyle.THIN);//左边框
        cell_style.setBorderTop(BorderStyle.THIN);//上边框
        cell_style.setBorderRight(BorderStyle.THIN);//右边框
        //自定义字体颜色, 同单元格样式
        HSSFFont font = workbook.createFont();
        font.setFontHeightInPoints((short) 9);
        //字体设置为Arial
        font.setFontName(HSSFFont.FONT_ARIAL);
        font.setFontHeight((short) 260);
        font.setBold(true);
        //将字体颜色设为白色
        //font.setColor((short)9);
        cell_style.setFont(font);
        return cell_style;
    }
}
